package com.ruoyi.business.modbus.domain;

/**
 * Modbus写入操作响应封装类
 *
 * @author ruoyi
 * @date 2024-01-01
 */
public class ModbusWriteResponse {

    /**
     * 操作是否成功
     */
    private boolean success;

    /**
     * 提示信息
     */
    private String message;

    /**
     * 设备编码
     */
    private String deviceSN;

    /**
     * 操作时间戳
     */
    private long timestamp;

    public ModbusWriteResponse() {
        this.timestamp = System.currentTimeMillis();
    }

    /**
     * 成功响应构造方法
     */
    public static ModbusWriteResponse success(String message, String deviceSN) {
        ModbusWriteResponse response = new ModbusWriteResponse();
        response.success = true;
        response.message = message;
        response.deviceSN = deviceSN;
        return response;
    }

    /**
     * 失败响应构造方法
     */
    public static ModbusWriteResponse failure(String message, String deviceSN) {
        ModbusWriteResponse response = new ModbusWriteResponse();
        response.success = false;
        response.message = message;
        response.deviceSN = deviceSN;
        return response;
    }

    // Getters and Setters
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getDeviceSN() {
        return deviceSN;
    }

    public void setDeviceSN(String deviceSN) {
        this.deviceSN = deviceSN;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public String toString() {
        return "ModbusWriteResponse{" +
                "success=" + success +
                ", message='" + message + '\'' +
                ", deviceSN='" + deviceSN + '\'' +
                ", timestamp=" + timestamp +
                '}';
    }
}
